package
{
	import flash.display.Sprite;
	import flash.events.TextEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.URLRequestMethod;
	import flash.text.TextField;
	import flash.text.TextFieldType;
	
	public class CaptureUserInput extends Sprite
	{
		private var myTextBox:TextField = new TextField();
		private var myOutputBox:TextField = new TextField();
		private var myText:String = "Input here"
			
		public function CaptureUserInput()
		{
			utcXML();
		}
		
		public function captureText():void
		{
			myTextBox.type = TextFieldType.INPUT;
			myTextBox.background = true;
			addChild(myTextBox);
			myTextBox.text = myText;
			myTextBox.addEventListener(TextEvent.TEXT_INPUT, textInputCapture);
		}
		
		public function textInputCapture(event:TextEvent):void
		{
			var str:String = myTextBox.text;
			createOutputBox(str);
		}
		
		public function createOutputBox(str:String):void
		{
			myOutputBox.background = true;
			myOutputBox.x = 200;
			addChild(myOutputBox);
			myOutputBox.text = str;
		}
		
		public function utcXML():void
		{
			var secondsUTC:Number = new Date().time;
			var dataXML:XML = 
				<login>
					<time>{secondsUTC}</time>
					<username>Ernie</username>
					<password>guru</password>
				</login>;
			var request:URLRequest = new URLRequest("http://www.yourdomain.com/login.cfm");
			request.contentType = "text/xml";
			request.data = dataXML.toXMLString();
			request.method = URLRequestMethod.POST;
			var loader:URLLoader = new URLLoader();
			try
			{
				loader.load(request);
				captureText();
			}
			catch (error:ArgumentError)
			{
				trace("An ArgumentError has occurred");
			}
			catch (error:SecurityError)
			{
				trace("A SecurityError has occurred");
			}
		}
	}
}